package com.itheima.domain;

import java.time.LocalDate;
import java.time.Period;
import java.util.ArrayList;

public class Student implements Comparable<Student>{

    private String sid;
    private String name;
    private String gender;
    private int age;
    private LocalDate birthday;
    private int group;//组编号
    private String phone;

    private ArrayList<String> wxs;

    public Student() {
    }

    public Student(String sid, String name, String gender, int age, LocalDate birthday, int group, String phone, ArrayList<String> wxs) {
        this.sid = sid;
        this.name = name;
        this.gender = gender;
        this.birthday = birthday;
        setAge();
        this.group = group;
        this.phone = phone;
        this.wxs = wxs;
    }

    public String getSid() {
        return sid;
    }

    public void setSid(String sid) {
        this.sid = sid;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public int getAge() {
        return age;
    }

    public void setAge() {
        Period between = Period.between(birthday, LocalDate.now());
        age = between.getYears();

    }

    public LocalDate getBirthday() {
        return birthday;
    }

    public void setBirthday(LocalDate birthday) {
        this.birthday = birthday;
        setAge();
    }

    public int getGroup() {
        return group;
    }

    public void setGroup(int group) {
        this.group = group;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public ArrayList<String> getWxs() {
        return wxs;
    }

    public void setWxs(ArrayList<String> wxs) {
        this.wxs = wxs;
    }

    @Override
    public String toString() {
        return "Student{" +
                "sid='" + sid + '\'' +
                ", name='" + name + '\'' +
                ", gender='" + gender + '\'' +
                ", age=" + age +
                ", birthday=" + birthday +
                ", group=" + group +
                ", phone='" + phone + '\'' +
                ", wxs=" + wxs +
                '}';
    }

    @Override
    public int compareTo(Student o) {
        return this.birthday.compareTo(o.birthday)==0?this.name.compareTo(o.name): this.birthday.compareTo(o.birthday);
    }
}
